package com.tarena.lbs.message.web.controller;

import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.message.web.service.TimingMsgTemplateService;
import com.tarena.lbs.pojo.message.dos.TimingMsgTemplate;
import com.tarena.lbs.pojo.message.param.TimingMsgTemplateInsertParam;
import com.tarena.lbs.pojo.message.param.TimingMsgTemplateUpdateParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 定时消息模板管理控制器
 */
@RestController
@RequestMapping("/admin/message/timingMsgTemplate")
@Api(tags = "定时消息模板管理")
@CrossOrigin
public class TimingMsgTemplateController {
    @Autowired
    TimingMsgTemplateService timingMsgTemplateService;

    /**
     * 新增定时消息模板
     *
     * @param timingMsgTemplateInsertParam 定时消息模板插入参数
     * @return Result<Boolean>对象
     */
    @ApiOperation("新增定时消息模板")
    @PostMapping("/insert")
    public Result<Boolean> insert(@RequestBody TimingMsgTemplateInsertParam timingMsgTemplateInsertParam) {
        boolean result = timingMsgTemplateService.insert(timingMsgTemplateInsertParam);
        return new Result<>(result);
    }

    /**
     * 查询所有定时消息模板
     *
     * @return Result<List<TimingMsgTemplate>>对象
     */
    @ApiOperation("查询所有定时消息模板")
    @PostMapping("/selectAll")
    public Result<List<TimingMsgTemplate>> selectAll() {
        List<TimingMsgTemplate> list = timingMsgTemplateService.selectAll();
        return new Result<>(list);
    }

    /**
     * 更新定时消息模板
     *
     * @param timingMsgTemplateUpdateParam 定时消息模板更新参数
     * @return Result<Boolean>对象
     */
    @ApiOperation("更新定时消息模板")
    @PostMapping("/updateById")
    public Result<Boolean> updateById(@RequestBody TimingMsgTemplateUpdateParam timingMsgTemplateUpdateParam) {
        boolean result = timingMsgTemplateService.UpdateById(timingMsgTemplateUpdateParam);
        return new Result<>(result);
    }

    /**
     * 删除定时消息模板
     *
     * @param id 定时消息模板编号
     * @return Result<Boolean>对象
     */
    @ApiOperation("删除定时消息模板")
    @PostMapping("/deleteById")
    @ApiImplicitParam(name = "id",value = "定时消息模板编号")
    public Result<Boolean> deleteById(Long id) {
        boolean result = timingMsgTemplateService.deleteById(id);
        return new Result<>(result);
    }
}
